home *** CD-ROM | disk | FTP | other *** search
/ Game.EXE 2001 January / Game.EXE_01_2001.iso / demos / Blade of Darkness / data1.cab / Program_Executable_Files / Lib / Blood.py < prev    next >
Encoding:
Text File  |  2000-11-16  |  7.1 KB  |  233 lines

  1. import Bladex
  2. import math
  3. import InitDataField
  4.  
  5. Evaporation      = 0      #  no evaporation avail  >:-(
  6. AfterCreateBlood = None   # CARLOS! PLEAS DON'T SAVE THIS VALUE...
  7.  
  8. def BloodPrtlHit(prtl_name,hit_entity,x,y,z,vx,vy,vz,wcx,wcy,wcz,wdx,wdy,wdz):
  9.     global Evaporation
  10.     p = Bladex.CreateEntity("BloodPool","Entity Pool",x,y,z)
  11.     prtl= Bladex.GetEntity(prtl_name);
  12.     try:
  13.         if(prtl.Data.evaporation):
  14.             p.DeathTime = Bladex.GetTime()+20.0
  15.         elif Evaporation:
  16.             p.DeathTime = Bladex.GetTime()+50.0
  17.     except:
  18.         if Evaporation:
  19.             p.DeathTime = Bladex.GetTime()+50.0
  20.             
  21.     if AfterCreateBlood:
  22.         AfterCreateBlood(x,y,z)
  23.     
  24. def GreenBloodPrtlHit(prtl_name,hit_entity,x,y,z,vx,vy,vz,wcx,wcy,wcz,wdx,wdy,wdz):
  25.     global Evaporation
  26.     p=Bladex.CreateEntity("BloodPool","Entity Pool",x,y,z)
  27.     p.Color = (96,192,96)
  28.     p.DeepColor = (64,128,64)
  29.     if Evaporation:
  30.         p.DeathTime = Bladex.GetTime()+50.0
  31.         
  32.     # Generate a smoke effect
  33.     smoke=Bladex.CreateEntity("FuegoVerde", "Entity Particle System D1", x, y, z)
  34.     smoke.ParticleType="VenomSmoke"
  35.     smoke.YGravity=-100.0
  36.     smoke.Friction=0.05
  37.     smoke.PPS=8
  38.     smoke.Velocity=0.0, -800.0, 0.0
  39.     smoke.RandomVelocity=5.0
  40.     smoke.DeathTime=Bladex.GetTime()+1.5
  41.  
  42. def GreyBloodPrtlHit(prtl_name,hit_entity,x,y,z,vx,vy,vz,wcx,wcy,wcz,wdx,wdy,wdz):    
  43.     global Evaporation
  44.     p=Bladex.CreateEntity("BloodPool","Entity Pool",x,y,z)
  45.     p.Color = (96,96,96)
  46.     p.DeepColor = (80,80,80)
  47.     if Evaporation:
  48.         p.DeathTime = Bladex.GetTime()+50.0
  49.  
  50.  
  51. def BleedFunc(blood_name,end_time,period):
  52.     blood=Bladex.GetEntity(blood_name)
  53.     if(blood):
  54.         prtl=blood.GetParticleEntity()
  55.         InitDataField.Initialise(prtl)
  56.         prtl.Data.evaporation=0
  57.         if blood.ParticleType=="GreenBlood":
  58.             prtl.HitFunc=GreenBloodPrtlHit
  59.         elif blood.ParticleType=="GreyBlood":
  60.             prtl.HitFunc=GreyBloodPrtlHit
  61.         else:                        
  62.             prtl.HitFunc=BloodPrtlHit
  63.             
  64.         if(Bladex.GetTime()<end_time):
  65.             Bladex.AddScheduledFunc(Bladex.GetTime()+period,BleedFunc,(blood_name,end_time,period),blood.Name+" BleedFunc")
  66.  
  67. AGE_Number=0
  68. def Bleed(objname,start_time,end_time,period,x=0.0,y=0.0,z=0.0,vx=0,vy=0,vz=0,ParticleType="Blood"):
  69.     global AGE_Number
  70.     AGE_Number=AGE_Number+1
  71.     blood=Bladex.CreateEntity("bleed_AGE_"+str(AGE_Number),"Entity Particle System D1",x,y,z)
  72.     blood.ParticleType=ParticleType
  73.     blood.YGravity=9800.0
  74.     blood.Friction=0.075
  75.     blood.PPS=512
  76.     blood.DeathTime=end_time+1.0/60.0;
  77.     blood.Velocity=vx,vy,vz
  78.     Bladex.GetEntity(objname).Link(blood)
  79.     Bladex.AddScheduledFunc(start_time,BleedFunc,(blood.Name,end_time,period),blood.Name+" BleedFunc")
  80.  
  81. def PersonBleed(per,start_time,end_time,period,x=0.0,y=0.0,z=0.0,vx=0,vy=0,vz=0,node=0):
  82.     global AGE_Number
  83.     if(node<0):
  84.         print("invalid node")
  85.         return
  86.  
  87.     AGE_Number=AGE_Number+1
  88.     blood=Bladex.CreateEntity("bleed_AGE_"+str(AGE_Number),"Entity Particle System D1",x,y,z)
  89.     if per.Kind=="Spidersmall":
  90.         blood.ParticleType="GreenBlood"
  91.     elif per.Kind=="Lich":
  92.         blood.ParticleType="GreyBlood"
  93.  
  94.     else:                
  95.         blood.ParticleType="Blood"
  96.     blood.YGravity=9800.0
  97.     blood.Friction=0.075
  98.     blood.PPS=512
  99.     blood.DeathTime=end_time+1.0/60.0;
  100.     blood.Velocity=vx,vy,vz
  101.     per.LinkToNode(blood,node)
  102.     Bladex.AddScheduledFunc(start_time,BleedFunc,(blood.Name,end_time,period),blood.Name+" BleedFunc")
  103.  
  104.  
  105. # Lista de entidades que tiran polvo
  106. SparkEntities     = ["Golem_metal","ChaosKnight"]
  107. DustDeathEntities = ["Skeleton","Lich","Golem_stone","Golem_clay","Golem_lava","Knight_Zombie"]+SparkEntities
  108.  
  109. def Mutilate(pj_name,obj_name,x,y,z,nx,ny,nz,node):
  110.     global DustDeathEntities
  111.     global SparkEntities
  112.     
  113.     vx=nx*2000.0
  114.     vy=ny*2000.0
  115.     vz=nz*2000.0
  116.     per= Bladex.GetEntity(pj_name)
  117.     if per.Kind in DustDeathEntities:
  118.         return
  119.     if per.Kind=="Spidersmall":
  120.         Bleed(obj_name,Bladex.GetTime()+0.0,Bladex.GetTime()+1.0,0.2,x,y,z,vx,vy,vz,"GreenBlood")
  121.     elif per.Kind=="Lich":
  122.         Bleed(obj_name,Bladex.GetTime()+0.0,Bladex.GetTime()+1.0,0.2,x,y,z,vx,vy,vz,"GreyBlood")
  123.     else:                    
  124.         Bleed(obj_name,Bladex.GetTime()+0.0,Bladex.GetTime()+1.0,0.2,x,y,z,vx,vy,vz)
  125.     x,y,z=Bladex.GetEntity(obj_name).Rel2AbsPoint(x,y,z)
  126.     PersonBleed(per,Bladex.GetTime()+0.0,Bladex.GetTime()+1.5,0.125,x,y,z,-2.0*vx,-2.0*vy,-2.0*vz,node)
  127.  
  128.  
  129.  
  130. def BleedingImpact(entity, x, y, z, ImpX, ImpY, ImpZ, weapon_entity,WeaponCx, WeaponCy, WeaponCz,WeaponDx, WeaponDy, WeaponDz):
  131.     global AGE_Number
  132.     global DustDeathEntities
  133.     global SparkEntities
  134.     
  135.     AGE_Number=AGE_Number+1    
  136.     
  137.     if entity.Kind in DustDeathEntities:
  138.         
  139.         dust=Bladex.CreateEntity("dust_AGE_"+str(AGE_Number),"Entity Particle System D1", x, y, z)
  140.         if entity.Kind == "Golem_clay":
  141.             dust.ParticleType="ShitSmoke"
  142.             dust.Time2Live=63
  143.             dust.PPS=60
  144.             dust.RandomVelocity=30.0
  145.         elif entity.Kind == "Golem_lava":
  146.             dust.ParticleType="LargeFire"
  147.             dust.Time2Live=31
  148.             dust.PPS=60
  149.             dust.RandomVelocity=30.0
  150.         elif entity.Kind in SparkEntities:
  151.             dust.ParticleType="Splinter"
  152.             dust.Time2Live=16
  153.             dust.PPS=128
  154.             dust.RandomVelocity=50.0
  155.         else:
  156.             dust.ParticleType="MediumDust"
  157.             dust.Time2Live=63
  158.             dust.PPS=60
  159.             dust.RandomVelocity=30.0
  160.             
  161.         dust.YGravity=0.0
  162.         dust.Friction=0.1
  163.         dust.Velocity=0.0, 0.0, 0.0
  164.         
  165.         dust.DeathTime=Bladex.GetTime()+4.0/60.0
  166.     
  167.     else:
  168.         time=Bladex.GetTime()
  169.         
  170.         if (weapon_entity):
  171.             stickblood=Bladex.CreateEntity("stickbleed_AGE_"+str(AGE_Number),"Entity Particle System D2", WeaponCx, WeaponCy, WeaponCz)
  172.             stickblood.D=WeaponDx, WeaponDy, WeaponDz
  173.             stickblood.YGravity=9800.0
  174.             stickblood.Friction=0.15
  175.             stickblood.Friction2=0.0
  176.             stickblood.DeathTime=time+0.4
  177.             
  178.             stickblood.RandomVelocity=100.0/60
  179.             stickblood.RandomVelocity_V=100.0/60
  180.             stickblood.Time2Live=26.0 # Maybe not necessarary
  181.             stickblood.Time2Live_V=6.0
  182.             stickblood.PPS=600
  183.             weapon_entity.Link(stickblood)
  184.         else:
  185.             stickblood=None
  186.         
  187.         
  188.         blood=Bladex.CreateEntity("bleed_AGE_"+str(AGE_Number),"Entity Particle System D1", x, y, z)
  189.         blood.YGravity=9800.0
  190.         blood.Friction=0.075
  191.         blood.PPS=600
  192.         blood.DeathTime=time+10.0/60.0;
  193.         blood.Position=x, y, z        
  194.         scale= math.sqrt(ImpX*ImpX+ImpY*ImpY+ImpZ*ImpZ)
  195.         if scale==0.0:
  196.             scale=1.0
  197.         scale = -2000.0 / scale # normalized scale by -2000.0
  198.         blood.Velocity=(ImpX*scale), (ImpY*scale)-2000.0, (ImpZ*scale)
  199.         blood.RandomVelocity=15.0
  200.         blood.RandomVelocity_V=10.0
  201.         blood.Time2Live=32
  202.         if stickblood:
  203.             prtl1=stickblood.GetParticleEntity()
  204.             InitDataField.Initialise(prtl1)
  205.             prtl1.Data.evaporation=1
  206.         else:
  207.             prtl1=blood.GetParticleEntity()
  208.             InitDataField.Initialise(prtl1)
  209.             prtl1.Data.evaporation=1
  210.         prtl2=blood.GetParticleEntity()        
  211.         InitDataField.Initialise(prtl2)
  212.         prtl2.Data.evaporation=1
  213.         if entity.Kind=="Spidersmall":
  214.             blood.ParticleType="GreenBlood"
  215.             if stickblood:
  216.                 stickblood.ParticleType="GreenBlood"
  217.             prtl1.HitFunc=GreenBloodPrtlHit
  218.             prtl2.HitFunc=GreenBloodPrtlHit
  219.         elif entity.Kind=="Lich":
  220.             blood.ParticleType="GreyBlood"
  221.             if stickblood:
  222.                 stickblood.ParticleType="GreyBlood"
  223.             prtl1.HitFunc=GreyBloodPrtlHit
  224.             prtl2.HitFunc=GreyBloodPrtlHit
  225.         else:                        
  226.             blood.ParticleType="Blood"
  227.             if stickblood:
  228.                 stickblood.ParticleType="Blood"
  229.             prtl1.HitFunc=BloodPrtlHit
  230.             prtl2.HitFunc=BloodPrtlHit
  231.             
  232.         
  233.